﻿Public Class frmListarMissionPrograma

    Private Sub frmListarMissionPrograma_Activated(sender As Object, e As EventArgs) Handles Me.Activated
        ModuloGeneral.Centrar(Panel1)
    End Sub

    Private Sub frmListarMissionPrograma_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        ModuloGeneral.Centrar(dgvListarMisionPrograma)

        Dim listaCC As New Dictionary(Of Integer, String)()
        listaCC = objGestor.listarProgramaInfo()

        Me.cbxPrograma.DataSource = New BindingSource(listaCC, Nothing)
        Me.cbxPrograma.DisplayMember = "Value"
        Me.cbxPrograma.ValueMember = "Key"

        With Me.dgvListarMisionPrograma

            .AutoGenerateColumns = False
            .AllowUserToAddRows = False
            .AllowUserToDeleteRows = False
            .Columns.Clear()
            .RowTemplate.Height = 150
            .Columns.Add("Id", "Id")
            .Columns.Add("Mision", "Mision")
            .Columns.Add("Tripulantes", "Tripulantes")
            .Columns.Add("FechaLanzamiento", "FechaLanzamiento")
            .Columns.Add("Duracion", "Duracion")
            .Columns.Add("DatosInteres", "DatosInteres")
            .Columns.Add("Resultado", "Resultado")
            .Columns.Add("Nave", "Nave")
            Dim imageColumn = New DataGridViewImageColumn()
            imageColumn.Name = "Insignia"
            imageColumn.ImageLayout = DataGridViewImageCellLayout.Zoom
            imageColumn.DefaultCellStyle.NullValue = Nothing
            .Columns.Add(imageColumn)
            .Columns(0).DataPropertyName = "Id"
            .Columns(0).Visible = False
            .Columns(0).Width = 10
            .Columns(1).DataPropertyName = "Nombre"
            .Columns(1).Visible = True
            .Columns(1).Width = 200
            .Columns(2).DataPropertyName = "Tripulantes"
            .Columns(2).Visible = True
            .Columns(2).Width = 100
            .Columns(3).DataPropertyName = "FechaLanzamiento"
            .Columns(3).Visible = True
            .Columns(3).Width = 100
            .Columns(4).DataPropertyName = "Duracion"
            .Columns(4).Visible = True
            .Columns(4).Width = 100
            .Columns(5).DataPropertyName = "DatosInteres"
            .Columns(5).Visible = True
            .Columns(5).Width = 100
            .Columns(6).DataPropertyName = "Resultado"
            .Columns(6).Visible = True
            .Columns(6).Width = 100
            .Columns(7).DataPropertyName = "Nave"
            .Columns(7).Visible = True
            .Columns(7).Width = 150
            .Columns(8).DataPropertyName = "Insignia"
            .Columns(8).Visible = True
            .Columns(8).Width = 200

        End With

    End Sub

    Private Sub cbxPrograma_SelectedIndexChanged(sender As Object, e As EventArgs) Handles cbxPrograma.SelectedIndexChanged
        Dim id As Integer = DirectCast(Me.cbxPrograma.SelectedItem, KeyValuePair(Of Integer, String)).Key()

        dgvListarMisionPrograma.DataSource = New BindingSource(objGestor.missionesDeProgramaEspacial(id), Nothing)
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Me.Close()
    End Sub
End Class